package com.ruangong.GitClient.HunHePanAPI;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.List;
import com.ruangong.GitClient.R;
public class TabListAdapter extends ArrayAdapter<Tab> {

    private Context context;
    private List<Tab> tabLists;

    public TabListAdapter(Context context, List<Tab> tabLists) {
        super(context, 0, tabLists);
        this.context = context;
        this.tabLists = tabLists;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        View listItem = convertView;
        if (listItem == null) {
            listItem = LayoutInflater.from(context).inflate(R.layout.item_tab_list, parent, false);
        }

        Tab currentTabList = tabLists.get(position);

        TextView nameTextView = listItem.findViewById(R.id.nameTextView);
        nameTextView.setText(currentTabList.getName());

        return listItem;
    }
}

